const readline = require("readline");

let chaxunzuarr = [];
let yonghushu = readline(),
  xihaoduarr = readline().split(" "),
  chaxunzushu = readline();
for (let i = 0; i < chaxunzushu; i++) {
  chaxunzuarr[i] = readline().split(" ");
}

let arr = [];
xihaoduarr.forEach((item, index) => {
  if (arr[item] == undefined) {
    arr[item] = [];
  }
  arr[item].push(index);
});
for (let j = 0; j < chaxunzushu; j++) {
  let start = chaxunzuarr[j][0] - 1,
    end = chaxunzuarr[j][1] - 1,
    value = chaxunzuarr[j][2],
    geshu = 0;
  if (arr[value] == undefined) {
    console.log(0);
  } else {
    arr[value].forEach((e) => {
      if (e >= start && e <= end) {
        geshu++;
      }
    });
    print(geshu);
  }
}
